package jnpf.engine.util;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;

/**
 * @author Doctor4JavaEE
 * @since 2024/4/12
 */
public class TimeUtils {
    public static void main(String[] args) throws ParseException {
        Date date = new Date();
        date.setTime(1713023981000L);

        System.err.println(DateFormatUtils.format(date,"yyyy-MM-dd HH:mm:ss"));



    }

    public static Date isoToDate(String isoDateStr) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
        Date parse = simpleDateFormat.parse(isoDateStr);
        return parse;
    }


    // Date 转 LocalDate
    public static LocalDateTime date2LocalDate(Date date) {
        return (date == null) ? (null) : (date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
    }

    /**
     * 通过天数计算秒
     */
    public static  Long getSecondsByDay(Long days){
        return days * 24 * 60 * 60;
    }
    /**
     * 通过天数计算秒
     */
    public static Long getSecondsByHour(Long hours){
        return hours  * 60 * 60;
    }
    /**
     * 通过天数计算秒
     */
    public static Long getSecondsByMinute(Long minutes){
        return minutes * 60;
    }
}
